<template>
  <div class="firmware">
    <div class="firmware-top">
      <el-button
        type="primary"
        plain
        icon="el-icon-setting"
        size="mini"
        @click="handleAuthorization"
        >配置MCP接入点</el-button
      >
    </div>
    <el-table :data="MCPList">
      <el-table-column label="接入点名称" sortable align="center" prop="brandName" />
      <el-table-column label="描述" align="center" prop="brandName" />
      <el-table-column label="公开" sortable align="center" prop="brandName" />
    </el-table>
    <MCP-dialog :open="open" @cancel="cancel" ref="child" />
  </div>
</template>

<script>
import MCPDialog from "./MCP-dialog";
export default {
  props: {
    MCPList: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {
      open: false,
    };
  },
  components: {
    MCPDialog,
  },
  methods: {
    handleEdit() {
      const { item } = this;
      this.$emit("handleEdit", item);
    },
    async handleDelete() {
      const { item } = this;
      try {
        const flag = await this.$modal.confirm("是否确认删除该数据项？");
        if (!flag) return;
        this.$emit("getList");
        this.$modal.msgSuccess("操作成功");
      } catch (error) {
        console.error("操作失败", error);
      }
    },
    handleGoDetail() {
      this.$router.push("/index/indexDetail/detail/" + 1);
    },
    cancel() {
      this.open = false;
    },
    rest() {
      this.$refs.child.resetFormFun();
    },
    handleAuthorization() {
      this.rest();
      this.open = true;
    },
  },
};
</script>

<style scoped lang="scss">
.firmware {
  margin: 0 0 22px 0;
  .firmware-top {
    margin-bottom: 22px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
  }
}
</style>
